#ifndef EVENTFILTER_H
#define EVENTFILTER_H

#include <QObject>
#include <QEvent>
#include <QKeyEvent>
#include <QMouseEvent>

class EventFilter : public QObject
{
	Q_OBJECT
public:
	explicit EventFilter(QObject *parent = nullptr);
	~EventFilter() = default;

	// funcs
	void setEnabled(bool enabled);
	void setIgnoredWindows(const QList<QWidget*> &windows);

signals:
	// keyborad 
	void keyPressed(QKeyEvent *event);
    void keyReleased(QKeyEvent *event);

	// mouse
	void mousePressed(QMouseEvent *event);
    void mouseReleased(QMouseEvent *event);
    void mouseMoved(QMouseEvent *event);

	// focus
	void focusChanged(QWidget *oldWidget, QWidget *newWidget);

protected:
	bool eventFilter(QObject *obj, QEvent *event) override;

private:
	// 判断是否需要忽略该对象的事件
    bool shouldIgnore(QObject *obj) const;
    
    bool m_enabled;                     // 是否启用过滤
    QList<QWidget*> m_ignoredWindows;   // 需要忽略的窗口

};


#endif	// EVENTFILTER_H